<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div>
        <a href="#/home">首页</a>
        <a href="#/list">列表</a>
        <a href="#/my">我的</a>
    </div>

    <div id="box">

    </div>

    <script>
        let box = document.getElementById('box')
        // hashChange
        window.addEventListener('hashchange', () => {
            let url = location.hash.slice(1)
            switch (url) {
                case "/home":
                    box.innerHTML = "我是首页"
                    break
                case "/list":
                    box.innerHTML = "我是列表"
                    break
                case "/my":
                    box.innerHTML = "我的页面"
                    break
            }
        })
    </script>
</body>

</html>